<?php
require_once '../application/library/helper/messageHelper.php';
require_once '../application/library/helper/configHelper.php';
require_once '../application/library/controller/gcLBasicAction.php';
require_once '../application/library/exception/gcExceptionDealer.php';
require_once '../application/modules/goods/constant/goods_constant_constant.php';
require_once '../application/modules/goods/constant/goods_constant_templatName.php';
require_once '../application/modules/goods/services/goods_services_goodsFormulaDetailService.php';
/**
 * 商品详细画面Controller
 * @version   1.0
 * @author    Suda
 */
class goods_goodsFormulaDetailController extends gcLBasicAction {

    private $objService;

    private $arrMessages = array();
    /**
    * 新规画面初期化
    * @throws gcException
    */
    public function indexAction() {
        try {
            $this->pvSetGoodsPageInfo();
            $strFormulaNo = $this->getParam("formulaNo");
            $this->objService = new goods_services_goodsFormulaDetailsService();
            $arrFormulaInfo = $this->objService->pbGetFormulaInfo($strFormulaNo);
            $arrFormulaItemInfo = $this->objService->pbGetFormulaItemInfoAndStockNum($strFormulaNo);
            $this->gcView->arrFormulaItemInfo = $arrFormulaItemInfo;
            $this->gcView->FormulaNo = $strFormulaNo;
            $this->gcView->arrFormulaInfo = $arrFormulaInfo;
            $this->gcView->render(goods_constant_TemplatName::GOODS_FORMULA_DETAILS);
        } catch (Exception $e) {
            gcExceptionDealer::setException($e);
        }
    }

    public function manufacturingAction() {
        try {
            $strProductGoodsNo = $this->getParam("ProductGoodsNo");
            $strManufacturingNum = $this->getParam("ManufacturingNum");
            $arrNeedNum = $this->getParam("arrNeedNum",true);
            $arrGoodsNo = $this->getParam("arrGoodsNo",true);
//            var_dump($arrGoodsNo,$arrNeedNum);exit;
            $this->objService = new goods_services_goodsFormulaDetailsService();
            $this->objService->pbUpdateProductNum($strProductGoodsNo,$strManufacturingNum);
            $this->objService->pbUpdateGoodsNum($arrNeedNum,$arrGoodsNo);
            $output = array();
            jsonHelper::outPutJson($output);
        } catch (Exception $e) {
            gcExceptionDealer::setException($e);
        }
    }

    /**
    * 画面信息设定
    * pvSetGoodsPageInfo
    */
    private function pvSetGoodsPageInfo() {
        $this->gcView->title                        = $this->getLabel("goods_EC0003_TopPageTitle");
        $this->gcView->goods_EC0007_Formula         = $this->getLabel("goods_EC0007_Formula");
        $this->gcView->goods_EC0007_FormulaDetail   = $this->getLabel("goods_EC0007_FormulaDetail");
        $this->gcView->goods_EC0007_GoodsName       = $this->getLabel("goods_EC0007_GoodsName");
        $this->gcView->goods_EC0007_Num             = $this->getLabel("goods_EC0007_Num");
        $this->gcView->goods_EC0007_InNum           = $this->getLabel("goods_EC0007_InNum");
        $this->gcView->goods_EC0007_Edit            = $this->getLabel("goods_EC0007_Edit");
        $this->gcView->goods_EC0007_Manufacturing   = $this->getLabel("goods_EC0007_Manufacturing");
        $this->gcView->goods_EC0007_Back            = $this->getLabel("goods_EC0007_Back");
        
    }
}